package com.github.chirspan.xaas.soa.message.processor;

import lombok.Getter;

/**
 * ************************
 * <p></p>
 * *************************
 *
 * @author chenpan
 * @date 2021/1/8 18:17
 */
public enum MessageProcessor {

    XML("XML", new XMLMessageProcessor());

    @Getter
    private String type;
    @Getter
    private AbstractMessageProcessor messageProcessor;

    MessageProcessor(String type, AbstractMessageProcessor messageProcessor) {
        this.type = type;
        this.messageProcessor = messageProcessor;
    }


    public static AbstractMessageProcessor getMessageProcessor(String type) {
        MessageProcessor[] types = values();
        for (MessageProcessor processor : types) {
            if (processor.type.equalsIgnoreCase(type)) {
                return processor.messageProcessor;
            }
        }
        return null;
    }
}
